#pragma once

#include<map>
#include<string>
struct SectionInfo
{
	SectionInfo() = default;
	~SectionInfo()
	{
		_section_datas.clear();
	}
	SectionInfo(const SectionInfo& src)
	{
		_section_datas = src._section_datas;
	}
	SectionInfo& operator=(const SectionInfo& src)
	{
		if (&src == this)
		{
			return *this;
		}
		_section_datas = src._section_datas;
		return *this;
	}

	std::string operator[](const std::string& key)
	{
		if (_section_datas.find(key) == _section_datas.end())
		{
			return "";
		}
		return _section_datas[key];
	}
	std::map<std::string, std::string> _section_datas;
};


class ConfigMgr
{
public:
	
	~ConfigMgr();
	ConfigMgr(const ConfigMgr& con);

	ConfigMgr& operator=(const ConfigMgr& con);

	SectionInfo operator[](std::string str);

	static ConfigMgr& Inst() {
		static ConfigMgr cfg_mgr;
		return cfg_mgr;
	}


private:
	ConfigMgr();
	std::map<std::string, SectionInfo> _config_map;
};

